package com.hevs.samplewebapp.client.screens;

import com.google.gwt.user.client.ui.Composite;
import com.hevs.samplewebapp.client.screenComponents.ScreenComponentStatistics;
import com.hevs.samplewebapp.client.services.StatisticsDataServiceImpl;

/**
 * Widget to display statistics for the patient
 * <p>It provides the patient tools to have a screen capable of displaying the statistics, choosing the range or the category</p>
 * @author Thomas Rouvinez
 * @Date: 23.04.2012
 */
public class StatisticsWidget extends Composite{

	// ----------------------------------------------------------------------------
	// Variables.
	// ----------------------------------------------------------------------------

	/**
	 * Initialization of the web service for the patient's statistics
	 * @see StatisticsDataServiceImpl
	 */
	private static StatisticsDataServiceImpl service = new StatisticsDataServiceImpl();

	/**
	 * Graphical Component of the statistics
	 * @see ScreenComponentStatistics
	 */
	public static ScreenComponentStatistics statistics = new ScreenComponentStatistics();
	
	// ----------------------------------------------------------------------------
	// Constructor.
	// ----------------------------------------------------------------------------

	/**
	 * Constructor of the Statistics widget
	 */
	public StatisticsWidget(){
		initWidget(statistics);
	}

	// ----------------------------------------------------------------------------
	// Methods.
	// ----------------------------------------------------------------------------

	/**
	 * Method to refresh data and the baked statistics.
	 */
	public void refresh(){
		// Get data from server.
		if(statistics.getDataProcessed() == false){
			service.getFullMedicalData();
		}
	}
}